package com.jsy.common.util.forest;

import com.dtflys.forest.Forest;
import com.dtflys.forest.config.ForestConfiguration;

public class ForestUtil {
    public static void main(String[] args) {
        // 创建Forest配置对象
        ForestConfiguration configuration = ForestConfiguration.configuration();
        configuration.setVariableValue("username", "foo");
        configuration.setVariableValue("userpwd", "bar");

        // 1.本地请求
        localRequest();
        // 2.Spring容器中请求
        //  springRequest();

    }

    private static void springRequest() {
        MyService myService = new MyService();
        myService.testClient();
    }

    private static void localRequest() {
        // 实例化Forest请求接口
        MyClient myClient = Forest.client(MyClient.class);
        // 调用Forest请求接口，并获取响应返回结果
        String result = myClient.helloForest();
        // 打印响应结果
        System.out.println(result);
    }
}
